<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core" >
    <h:head>
        <title>Home Overview</title>
    </h:head>
    <h:body>
        Username : #{homeBean.twitterer.userName} <br/>
        Account status platinum : #{homeBean.twitterer.platinumTwitterer}
       
        <h:form>
        <p:commandButton value="Logout" action="#{loginBean.logout()}" immediate="true"/>
            <p:dataTable value="#{homeBean.favorites}" var="twitterer" id="table" style="width: 640px">
                <f:facet name="header">  
                    List Of Favorites
                </f:facet>  
                <p:column>
                    <f:facet name="header">UserName</f:facet>
                        #{twitterer.userName}
                </p:column>
                <p:column>
                    <f:facet name="header">Read</f:facet>
                    <p:commandButton value="Read" action="#{homeBean.readMessages(twitterer)}" immediate="true"/>                  
                </p:column>
                <p:column>
                    <f:facet name="header">Remove</f:facet>
                    <p:commandButton value="Remove" action="#{homeBean.removeFavorite(twitterer)}" update="table" />                  
                </p:column> 
                <f:facet name="footer">  
                    In total there are #{homeBean.twitterer.favorites.size()} favorites. <br/>
                    You have placed #{homeBean.postedMessages()} messages.    
                </f:facet>  
            </p:dataTable>
            <p:commandButton value="Read Messages" action="#{homeBean.toTwittererOverView()}" immediate="true"/>  
            <p:commandButton value="Create Message" action="#{homeBean.toNewMessage()}" immediate="true"/>
            <p:commandButton value="Delete Acount" action="#{homeBean.deleteAccount()}" immediate="true"/>
            <c:set var="postedMessages" scope="request" value="#{homeBean.postedMessages()}"/>
            <c:if test="${postedMessages > 1}">
                <p:commandButton value="Upgrade" action="#{homeBean.upgradeAccount()}" immediate="true"/>
            </c:if>
        </h:form>
    </h:body> 
</html>
